package com.youngwang.lambda;

import com.youngwang.lambda.infa.Converter;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.Supplier;

/**
 * 函数式接口测试
 * @author youngwang
 * Date: 2016/10/13
 */
public class ConverterTest {
    public static void main(String[] args){
        Converter<String, Integer> converter = Integer::valueOf;

        System.out.print(converter.convert("123"));


        Supplier<Integer> supplier = () -> 2;

        BiFunction<Integer, String, String> biFunction = (i, s) -> {
            if(Integer.valueOf(s).compareTo(i) > 0){
                return s;
            }else {
                return String.valueOf(i);
            }
        };
        Function<String, Integer> function = Integer::valueOf;

        biFunction.andThen(function).apply(1, "2");

        IntPredicate intPredicate = (i) -> 4 > i;
        IntPredicate intPredicate1 = (i) -> i > 0;
        System.out.println(intPredicate.and(intPredicate1).test(4));


    }
}
